<?php
require("./Curl.php");

class Daily{

	public static function GetDetailTitle(){
		$url = "http://news-at.zhihu.com/api/4/news/latest";
		$data = Curl::CurlGet($url); 
		$data = json_decode($data);
		$data = self::ObjectArray($data);
		// $strdata = "";
		// foreach ($data['stories'] as $key => $value){
		// 	$strdata .= $value['title']."\n\n";
		// }
		// return $strdata;
		var_dump($data['stories']);
		return $data['stories'];
	}

	public static function ObjectArray($array){
		if(is_object($array)){
			$array = (array)$array;
		}
		if(is_array($array)){
			foreach ($array as $key => $value) {
				$array[$key] = self::ObjectArray($value);
			}
		}
		return $array;	
	}




}

$DetailTitle = Daily::GetDetailTitle();
$data = [];
foreach ($DetailTitle as $key => $value) {
  $data =[
    'title'=>$value['title'],
     'url'=>"http://www.baidu.com",
     'picurl'=>$value['images'][0],
     'desc'=>$value['title']
  ];
}

var_dump($data)

?>